package com.bz.content.controller;

import com.bz.content.service.ContentService;
import com.bz.pojo.TbContent;
import com.bz.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/content")
public class ContentController {

    @Autowired
    private ContentService contentService;

    /**
     * 根据分类查询内容
     * @param page
     * @param rows
     * @param categoryId
     * @return
     */
    @GetMapping("/selectTbContentAllByCategoryId")
    public Result selectTbContentAllByCategoryId(@RequestParam(defaultValue = "1")Integer page,@RequestParam(defaultValue = "10")Integer rows,@RequestParam Long categoryId){
        return contentService.selectTbContentAllByCategoryId(page,rows,categoryId);
    }

    /**
     * 根据分类添加内容
     * @param tbContent
     * @return
     */
    @PostMapping("/insertTbContent")
    public Result insertTbContent(TbContent tbContent){
        return contentService.insertTbContent(tbContent);
    }

    /**
     * 删除分类下的内容
     * @param id
     * @return
     */
    @GetMapping("/deleteContentByIds")
    public Result deleteContentByIds(Long id){
        return contentService.deleteContentByIds(id);
    }
}